#include <iostream>
#include <vector>
#include <gtest/gtest.h>

using namespace std; 

class Solution
{

public:

// time complexity O(n)
// space complexity O(1)
int solve(int A) {
    
    if (A == 1)
        return 1; 
    
    int min_steps = 0, bulbs_left = A; 

    int n = A / 2; 
    for (int i = 0; i < n;)
    {
        if (bulbs_left <= 0)
            break; 
        if (i + 1 < n && i + 2 < n)
        {
            bulbs_left -= 3;
            i += 3; 
        }
        else if (i + 1 < n)
        {
            bulbs_left -= 2;
            i += 2; 
        }
        else 
        {
            bulbs_left -= 1;
            i += 1;    
        }
        ++min_steps;
    }
    min_steps *= 2; 
    
    if (A % 2 == 1 && n % 3 == 0)
        min_steps += 1; 
        
    return min_steps; 
}

}; 

TEST(TestSolution, SimpleTest)
{
    const int A = 22015;
    Solution s; 
    EXPECT_EQ(s.solve(A), 7339) << "wrong answer";
}

int main()
{
    testing::InitGoogleTest();
    return RUN_ALL_TESTS();
}
